#lang racket
(provide commuter_ij)
(define (get-element-fct lst id indice)
  (cond [(empty? lst) empty]
        [(eqv? id indice) (car lst)]
        [(get-element-fct (cdr lst) id (add1 indice))]))

(define (get-element lst id)
  (get-element-fct lst id 0))

(define (list-switch lst idx val)
  (if (null? lst)
    lst
    (cons
      (if (zero? idx)
        val
        (car lst))
      (list-switch (cdr lst) (- idx 1) val))))

(define (commuter_ij lst ida idb)
  (if (empty? lst)
      lst
      (if (or (zero? ida) (< (length lst) idb)) 
         (print "Segmentation fault")
         (list-switch  (list-switch '(∧ a (∨ b c) (¬ (¬ (∨ d b)))) idb
                                   (get-element '(∧ a (∨ b c) (¬ (¬ (∨ d b)))) ida)
                                   ) ida (get-element '(∧ a (∨ b c) (¬ (¬ (∨ d b)))) idb)))))
'(commuter_ij '(∧ a (∨ b c) (¬ (¬ (∨ d b)))) 1 3)
(commuter_ij '(∧ a (∨ b c) (¬ (¬ (∨ d b)))) 1 3)

'(commuter_ij '(∧ a b c d e f) 0 4)
(commuter_ij '(∧ a b c d e f) 0 4)